package models;

import com.et.ar.ActiveRecordBase;
import com.et.ar.annotations.BelongsTo;
import com.et.ar.annotations.Column;
import com.et.ar.annotations.Id;
import com.et.ar.annotations.Table;
import com.et.ar.annotations.Unique;

import java.sql.*;

import rbac.models.PrivilegeType;
import utils.DateUtil;


@Table(name="infos")
public class Info extends ActiveRecordBase{
	@Id private Integer id;
	@Column private Integer infotypeid;
	@Column private String title;
	@Column private String infofrom;
	@Column private String oper;
	@Column private Timestamp inputdate;
	@Column private Timestamp editdate;
	@Column private String content;
	@Column private Integer passflag;
	@Column private Integer totop;
	@Column private Integer hot;
	@BelongsTo(foreignKey = "infotypeid")
	private Infotype infotype;

	
	public String getShoweditdate(){		
		return DateUtil.formatter("yyyy-MM-dd", editdate.getTime());
	}
	//	@BelongsTo(foreignKey="demoId")
	//	private Demo demo;

	//	public Demo getDemo() {
	//		return demo;
	//	}
	//	public void setDemo(Demo demo) {
	//		this.demo = demo;
	//	}

	//	public int getChildCount() throws Exception {
	//		return (int)count(Info.class, "parentId=?", new Object[]{id});
	//	}
	//	public String findChildIds() throws Exception {
	//		String s = "";
	//		List<Integer> ids = new ArrayList<Integer>();
	//		ids.add(id);
	//		while(!ids.isEmpty()){
	//			int id = ids.remove(0);
	//			s += id + ",";
	//			for(Info item: Info.findAll(Info.class, "parentId=?", new Object[]{id})){
	//				ids.add(item.getId());
	//			}
	//		}
	//		if (!s.equals("")){
	//			s = s.substring(0, s.length() - 1);
	//		}
	//		return s;
	//	}
	public void setId(Integer id){
		this.id=id;
	}
	public Integer getId(){
		return id;
	}

	public void setInfotypeid(Integer infotypeid){
		this.infotypeid=infotypeid;
	}
	public Integer getInfotypeid(){
		return infotypeid;
	}

	public void setTitle(String title){
		this.title=title;
	}
	public String getTitle(){
		return title;
	}

	public void setInfofrom(String infofrom){
		this.infofrom=infofrom;
	}
	public String getInfofrom(){
		return infofrom;
	}

	public void setOper(String oper){
		this.oper=oper;
	}
	public String getOper(){
		return oper;
	}

	public void setInputdate(Timestamp inputdate){
		this.inputdate=inputdate;
	}
	public Timestamp getInputdate(){
		return inputdate;
	}

	public void setEditdate(Timestamp editdate){
		this.editdate=editdate;
	}
	public Timestamp getEditdate(){
		return editdate;
	}

	public void setContent(String content){
		this.content=content;
	}
	public String getContent(){
		return content;
	}

	public void setPassflag(Integer passflag){
		this.passflag=passflag;
	}
	public Integer getPassflag(){
		return passflag;
	}

	public void setTotop(Integer totop){
		this.totop=totop;
	}
	public Integer getTotop(){
		return totop;
	}

	public void setHot(Integer hot){
		this.hot=hot;
	}
	public Integer getHot(){
		return hot;
	}

	public Infotype getInfotype() {
		return infotype;
	}

	public void setInfotype(Infotype infotype) {
		this.infotype = infotype;
	}
}

